<template>
  <view class="notLoggedIn">
    <view class="title">
      <view></view>
      <language />
    </view>
    <view class="com">
      <view>
        <view>您好，請登錄</view>
        <view>請輸入郵箱及密碼</view>
      </view>
      <view>
        <view class="t1">
          <up-input
            placeholder="請輸入郵箱"
            v-model="user_name"
            clearable
            border="none"
          ></up-input>
        </view>
        <view class="t2">
          <up-input
            placeholder="請輸入密碼"
            v-model="pass_word"
            clearable
            :password="!showPsw"
            border="none"
          >
            <template #suffix>
              <i
                @tap="showPsw = !showPsw"
                :class="showPsw ? 'open' : 'eye'"
              ></i>
            </template>
          </up-input>
        </view>
      </view>
      <view class="forgot">忘記密碼 ？</view>
      <view class="btn">
        <up-button
          :disabled="!pass_word || !user_name"
          text="登錄"
          @tap="LogonFn"
          type="primary"
        ></up-button>
      </view>
      <view
        class="agreement"
        @tap="isAgreement = !isAgreement"
        :class="{ active: isAgreement }"
      >
        我已閱讀並同意<text @tap.stop>《服務條款》</text>和<text @tap.stop
          >《隱私政策》</text
        >
      </view>
      <view class="fot">
        還沒有帳號？<text @tap="goTo('/pages/notLoggedIn/register')"
          >立即註冊</text
        >
      </view>
    </view>
  </view>
</template>

<script setup lang="ts">
import { ref, getCurrentInstance } from "vue";
import { Logon } from "@/api/UserApi";
const instance = getCurrentInstance()?.appContext.config.globalProperties;
uni.removeStorageSync("userInfo");
uni.removeStorageSync("FriendApply");

let showPsw = ref<boolean>(false);
let isAgreement = ref<boolean>(true);
let user_name = ref<string>("1@qq.com");
let pass_word = ref<string>("123123a");
// let user_name = ref<string>("");
// let pass_word = ref<string>("");
const LogonFn = () => {
  if (!isAgreement.value) {
    uni.showToast({ title: "請勾選服務條款", icon: "none" });
    return;
  }
  Logon({
    user_name: user_name.value,
    pass_word: instance?.getRsaCode(pass_word.value),
    loading: 1,
  });
};
</script>
<style scoped lang="scss">
@import "@/static/scss/notLoggedIn.scss";
</style>
